<?php

namespace App\Admin\Controllers;

use App\Models\WechatTemplate;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class WechatTemplateController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '消息模版';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new WechatTemplate());

        $grid->column('id', __('ID'))->sortable();
        $grid->column('tpl_id', __('模版ID'));
        $grid->column('tpl_name', __('模版标题'));
        $grid->column('create_time', __('创建时间'));
        $grid->column('update_time', __('更新时间'));
        $grid->column('tpl_content', __('模版内容'));
        $grid->disableActions();
        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(WechatTemplate::findOrFail($id));

        $show->field('id', __('ID'));
        $show->field('tpl_id', __('模版ID'));
        $show->field('tpl_name', __('模版名称'));
        $show->field('create_time', __('创建时间'));
        $show->field('update_time', __('更新时间'));
        $show->field('tpl_content', __('模版内容'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new WechatTemplate());

        $form->text('tpl_id', __('模版ID'));
        $form->text('tpl_name', __('模版名称'));
        $form->text('tpl_content', __('模版内容'));

        return $form;
    }
}
